<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="kr.co.insoft.framework.config.Authorities"%>
<c:set var="CONTEXT">${pageContext.request.contextPath}</c:set>
<c:set var="cssUrl">${pageContext.request.contextPath}/resources/css</c:set>
<c:set var="jsUrl">${pageContext.request.contextPath}/resources/js</c:set>

<spring:message code="button.search.text" var="searchText"/>
<div class="col-sm-12 page-header custom-page-header">
	<h1><spring:message code="menu.eventchain.eventchain"/></h1>							  	
</div>
<form:form modelAttribute="eventChainPagingModel" role="form" cssClass="col-sm-12">
	<input id="currentPage" name="currentPage" type="hidden" value="${eventChainPagingModel.currentPage}" />
	<div class="row"></div>
	<h3>Event Chain List</h3>
	<div class="col-sm-12 form-group" style="margin-top: 15px;">
		<label class="col-sm-offset-1 col-sm-2 control-label text-right">Chain Type</label>
		<div class="col-sm-2">
			<select name="eventChainTypes" class="form-control">
				<option value="">All</option>
				<c:forEach items="${chainTypes }" var="type">
					<option value="${type }">${type }</option>
				</c:forEach>
			</select>		
		</div>
		
		<div class=" col-sm-5">
			<div class="input-group">
				<input type="text" placeholder="Event Chain명을 입력하세요" name="searchAndCondition['chainName']" class="form-control" value="${eventChainPagingModel.searchAndCondition['chainName']}" />
				<span class="input-group-btn">
					<button class="btn btn-primary"><spring:message code="button.search"/></button> 
				</span>
			</div>
		</div>
		<div class="col-sm-2">
		<form:select path="viewRow" cssClass="form-control">
			<form:option value="10">10 개</form:option>
			<form:option value="25">25 개</form:option>
			<form:option value="50">50 개</form:option>
			<form:option value="100">100 개</form:option>
		</form:select>
		</div>
	</div>
	
	<div class="form-group">				
		<table class="table table-hover">
			<thead>
				<tr>
					<th>Event Chain Type</th>
					<th>Project</th>
					<th>Service</th>
					<th>Composite</th>
					<th>EventChain</th>					
				</tr>
			</thead>
			<tbody>
				<c:choose>
					<c:when test="${empty eventChainPagingModel.lists }">
						<tr class="warning">
							<td colspan="5"><spring:message code="list.no.result"/></td>
						</tr>
					</c:when>
					<c:otherwise>
						<c:forEach items="${eventChainPagingModel.lists }" var="item">
							<tr>
								<td>${item.chainType }</td>
								<td>${item.projectName }</td> 
								<td>${item.serviceName }</td>
								<td>${item.composite }</td>
								<td>${item.chainName }</td>
							</tr>
						</c:forEach>
					</c:otherwise>
				</c:choose>
			</tbody>
		</table>
	</div>

	<div class="form-group text-center">
		<c:if test="${not empty eventChainPagingModel.lists }">
			<ul class="pagination">
				<li><a href="#" class="pages" data-page="${eventChainPagingModel.paging.previousBlock }">&laquo;</a></li>
				<c:forEach items="${eventChainPagingModel.paging.pages }" var="pages">
					<c:choose>
						<c:when test="${pages eq eventChainPagingModel.paging.currentPageNum }">
							<li class="active"><a href="#" class="pages" data-page="${pages }">${pages }</a></li>
						</c:when>
						<c:otherwise>
							<li><a href="#" class="pages" data-page="${pages }">${pages }</a></li>
						</c:otherwise>
					</c:choose>
				</c:forEach>
				<li><a href="#" class="pages" data-page="${eventChainPagingModel.paging.nextBlock}">&raquo;</a></li>
			</ul>
		</c:if> 
	</div>
	<div class="text-right">
		<c:if test="${fn:contains(buttons , Authorities.CREATE)}">
			<button type="button" class="btn btn-primary btnChainCreate"><spring:message code="button.create"/></button>
		</c:if>
	</div>
</form:form>